
#ifndef __GAME_HUD_LAYER_H__
#define __GAME_HUD_LAYER_H__

namespace nGameLogic
{
	struct sMSG_ScoreChanged;
	struct sMSG_GameOver;
	struct sMSG_StageClear;
}

class cGameHUDLayer : public CCLayer, public iMsgTargetBase
{
	DECLARE_MSG_MAP()

public:
	cGameHUDLayer();
	~cGameHUDLayer();

	bool init();
	void update(ccTime dt);

	tMsgTargetID GetMsgTargetID() const { return MSG_TARGET_HUD_LAYER; }

	// implement the "static node()" method manually
	LAYER_NODE_FUNC(cGameHUDLayer);

	void SetScore(tInt score);
	void SetGameOver();
	void SetStageClear();

	// munu handlers
	void OnRestart(CCObject* pSender);

private:
	void Handle(const nGameLogic::sMSG_ScoreChanged& msg);
	void Handle(const nGameLogic::sMSG_GameOver& msg);
	void Handle(const nGameLogic::sMSG_StageClear& msg);

private:
	// score bar
	CCSprite* m_scoreBar;
	cTimeCounter m_scoreBarTimer;
	tFloat m_scoreBarWidth;

	tInt m_score;
	tInt m_prevScore;
	tInt m_scoreVariation;

	// restart menu
	CCLabelTTF* m_labelGameOver;
	CCLabelTTF* m_labelStageClear;
	CCMenu* m_restartMenu;
};

#endif